﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutumnEngine.Modules
{
    /// <summary>
    /// Manages game content.
    /// </summary>
    public class ContentManagerModule : Module
    {
        /// <summary>
        /// Creates this instance.
        /// </summary>
        public override void Create()
        {
            this.Removable = false;
            this.CanBeDisabled = false;
            base.Create();
        }
        /// <summary>
        /// Loads the asset at the specified path.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public T Load<T>(string path)
        {
            if (Engine.Modules.Contains("Engine.Logging"))
                Engine.Modules.Logging.Write("Loading asset " + path, LogLevel.Debug);
#if WINDOWS
            if (!path.StartsWith("Content"))
                return Engine.ContentManager.Load<T>(System.IO.Directory.GetCurrentDirectory() + "/Content/" + path);
            else
            {
                return Engine.ContentManager.Load<T>(System.IO.Directory.GetCurrentDirectory() + "/" + path);

            }
#else
            if(!path.StartsWith("Content"))
            return Engine.ContentManager.Load<T>(Microsoft.Xna.Framework.Storage.StorageContainer.TitleLocation + "/Content/" + path);
            else
            return Engine.ContentManager.Load<T>(Microsoft.Xna.Framework.Storage.StorageContainer.TitleLocation + "/" + path);

#endif
        }
    }
}
